package com.ayoka.parenting.ui.coach.invitedrecord;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.BasicUserInfoBean;
import com.ayoka.parenting.interf.SimpleRequestCallback;
import com.ayoka.parenting.mvp.BasePresenterImpl;
import com.jincp.common.utils.UIUtils;

import java.util.List;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: InvitedRecordPresenter.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class InvitedRecordPresenter extends BasePresenterImpl<InvitedRecordContract.View> implements InvitedRecordContract.Presenter{

    private InvitedRecordModel model;

     public InvitedRecordPresenter() {
        model = new InvitedRecordModel();
     }

    @Override
    public void getInvitedRecordListData(boolean isShowWaitDialog, int pageNo, int pageSize) {
        if (isShowWaitDialog) {
            mView.get().showWaitDialog(UIUtils.getString(R.string.loading));
        }
        model.getInvitedRecordListData(this, pageNo, pageSize, new SimpleRequestCallback<List<BasicUserInfoBean>>() {
            @Override
            public void onSuccess(List<BasicUserInfoBean> data) {
                if (!isAttached()) return;
                mView.get().hideWaitDialog();
                mView.get().configInvitedRecordListData(data);
            }

            @Override
            public void onFailure(int errCode, String errMsg) {
                if (!isAttached()) return;
                mView.get().hideWaitDialog();
                mView.get().showToast(errMsg);
            }
        });
    }
}
